package cn.itchao.example.goods.controller;

import cn.itchao.example.goods.service.GoodsService;
import cn.itchao.example.member.dto.MemberDto;
import cn.itchao.exmaple.base.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@RestController
public class GoodsController {

    @Autowired
    private GoodsService goodsService;

    @GetMapping("/goods/member/dubbo/{id}")
    public ApiResponse findMemberDubboById(@PathVariable("id") Long id){
        MemberDto memberDto = goodsService.findMemberDubboById(id);
        return ApiResponse.ofSuccess(memberDto);
    }

    @GetMapping("/goods/member/rest/{id}")
    public ApiResponse findMemberRestById(@PathVariable("id") Long id) throws IOException {
        MemberDto memberDto = goodsService.findMemberRestById(id);
        return ApiResponse.ofSuccess(memberDto);
    }

    @GetMapping("/goods/member/dubbo/rest/{id}")
    public ApiResponse findMemberDubboRestById(@PathVariable("id") Long id) throws IOException {
        MemberDto memberDto = goodsService.findMemberDubboRestById(id);
        return ApiResponse.ofSuccess(memberDto);
    }
}
